import Vue from 'vue'
import VueRouter from 'vue-router'

import recommend from '../components/home/recommend.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect: "/home/recommend"
  },

  {
    path: "/login",
    name: "login",
    component: () => import("../components/base/login.vue"),
  },
  {
    path: "/loginlist",
    name: "loginlist",
    component: () => import("../components/base/loginlist.vue"),
  },
  // {
  //   path: "/home",
  //   name: "home",
  //   component: home,
  // },
  {
    path: "/home/recommend",
    name: "recommend",
    component: recommend,
    // component: () => import("../components/home/recommend.vue")
  },
  {
    path: "/film",
    name: "film",
    component: () => import("../views/film.vue")
  },
  {
    path: "/Small-video",
    name: "Small-video",
    component: () => import("../views/Small-video.vue")
  },
  {
    path: "/show",
    name: "show",
    component: () => import("../views/show.vue"), beforeEnter: (to, from, next) => {
      let login = window.localStorage.getItem("token");
      if (!login) {
        next("/login");
        return;
      } else {
        next();
      }
    }
  },
  {
    path: "/my",
    name: "my",
    component: () => import("../views/my.vue"), beforeEnter: (to, from, next) => {
      let login = window.localStorage.getItem("token");
      if (!login) {
        next("/login");
        return;
      } else {
        next();
      }
    }
  },
  {
    path: "/home/watch",
    name: "watch",
    component: () => import("../components/home/watch.vue")
  },
  {
    path: "/home/unscramble",
    name: "unscramble",
    component: () => import("../components/home/unscramble.vue")
  },
  {
    path: "/home/Notice",
    name: "Notice",
    component: () => import("../components/home/Notice.vue")
  }
  ,
  {
    path: "/home/consulting",
    name: "consulting",
    component: () => import("../components/home/consulting.vue")
  },
  {
    path: "/my/setup",
    name: "setup",
    component: () => import("../components/my/setup.vue")
  },
  {
    path: "/Search/search",
    name: "search",
    component: () => import("../components/Search/search.vue")
  },
  {
    path: "/Search/establish",
    name: "establish",
    component: () => import("../components/Search/establish.vue")
  },
  {
    path: "/Search/searchlist",
    name: "searchlist",
    component: () => import("../components/Search/searchlist.vue")
  },
  {
    path: "/Search/classification",
    name: "classification",
    component: () => import("../components/Search/classification.vue")
  },
  {
    path: "/Search/tongzhilist",
    name: "tongzhilist",
    component: () => import("../components/Search/tongzhilist.vue")
  },
  {
    path: "/recipe/recipelist",
    name: "recipelist",
    component: () => import("../components/recipe/recipelist.vue")
  },
  {
    path: "/recipe/videolist",
    name: "videolist",
    component: () => import("../components/recipe/videolist.vue")
  },
  {
    path: "/note/notelist",
    name: "notelist",
    component: () => import("../components/note/notelist.vue")
  },
  {
    path: "/note/notelists",
    name: "notelists",
    component: () => import("../components/note/notelists.vue")
  },
]

const router = new VueRouter({
  routes
})

export default router
